﻿namespace PlaylistCopy.Services.Impl
{
    using CuttingEdge.Conditions;
    using Ookii.Dialogs.Wpf;
    using PlaylistCopy.Localization;

    public class NotificationService : INotificationService
    {
        public Localizer T { get; set; }

        public NotificationService()
        {
            this.T = NullLocalizer.Instance;
        }

        public void Error(string message)
        {
            Condition.Requires(message, "message").IsNotNullOrWhiteSpace();

            var taskDialog = new TaskDialog();

            taskDialog.Buttons.Add(NewOkButton());
            taskDialog.Content = message;
            taskDialog.ButtonStyle = TaskDialogButtonStyle.Standard;
            taskDialog.MainInstruction = this.T("ErrorOccured");
            taskDialog.WindowTitle = this.T("Error");

            taskDialog.ShowDialog();
        }

        public void Info(string message, string title)
        {
            Condition.Requires(message, "message").IsNotNullOrWhiteSpace();

            var taskDialog = new TaskDialog();

            taskDialog.Buttons.Add(NewOkButton());
            taskDialog.Content = message;
            taskDialog.ButtonStyle = TaskDialogButtonStyle.Standard;
            taskDialog.MainInstruction = title;
            taskDialog.WindowTitle = this.T("Info");

            taskDialog.ShowDialog();
        }

        private static TaskDialogButton NewOkButton()
        {
            return new TaskDialogButton("OK")
                   {
                       ButtonType = ButtonType.Ok,
                   };
        }
    }
}
